
var ImageCommon = {
    id: "ImageTable",	//表格id
    currentTarget:null,
    multipart:null,
    w:0,
    h:0,
    layerIndex: -1
};
//添加图片
ImageCommon.add=function (targetId,w,h,multipart,imgPath,scale) {
    this.currentTarget=$('#'+targetId);
    this.multipart=multipart;
    this.w=w;
    this.h=h;
    this.scale = scale||1;//缩小比例
    var w_layer =1200 >document.body.clientWidth*0.8?document.body.clientWidth*0.8:1200;
    var h_layer  = 550;
    var index = layer.open({
        type: 2,
        shade: [0.5,'FFFFFF'],
        title: '选择图片',
        offset: '30px',
        area: [w_layer+'px', h_layer+'px'], //宽高
        fix: false, //不固定
        maxmin: true,
        content: Feng.ctxPath + '/uploadImage?multipart='+multipart+'&w='+ImageCommon.w+'&h='+ImageCommon.h+'&scale='+ImageCommon.scale+'&imgPath='+imgPath
    });
    this.layerIndex = index;

};
//回调函数
ImageCommon.callFun=function (seItems) {
    if(ImageCommon.currentTarget!=null&&ImageCommon.multipart!=null && ImageCommon.w>0&& ImageCommon.h>0){
        var $target =$(ImageCommon.currentTarget);
        if( ImageCommon.multipart=='false'||ImageCommon.multipart==false){//单选
            var item =seItems[0];
            var  node=[];
            node.push('<div data-fileurl="'+item+'" class="addDiv" style="width: '+(ImageCommon.w/ImageCommon.scale)+'px;height: '+(ImageCommon.h/ImageCommon.scale)+'px;">');
            node.push('<img src="'+item+'">');
            node.push(' <a class="js-delete-picture close-modal small" onclick="ImageCommon.delItem(this);">×</a>');
            node.push(' </div>');
            $target.html(node.join(''));
        }else{//多选

            var  node=[];
            for(var i=0;i<seItems.length;i++){
                var item =seItems[i];
                node.push('<div data-fileurl="'+item+'" class="addDiv" style="width: '+(ImageCommon.w/ImageCommon.scale)+'px;height: '+(ImageCommon.h/ImageCommon.scale)+'px;">');
                node.push('<img src="'+item+'">');
                node.push(' <a class="js-delete-picture close-modal small" onclick="ImageCommon.delItem(this);">×</a>');
                node.push(' </div>');
            }
            $target.append(node.join(''));
        }
        //锚点定位
        Container.myHash($target.attr('id'));
    }

};
//删除图片
ImageCommon.delItem=function (elem) {
$(elem).parents('.addDiv').remove();
};

